﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CalculatorLib.Interface;
using CalculatorLib.Model;

namespace CalculatorLib
{
    public class MainCalculator
    {
        #region Private Fields

        private IBasicCalculator _calculator;
        private CalModel _data;

        #endregion

        #region Constructor

        public MainCalculator()
        {
            this._calculator = new  BasicCalculator();
        }

        #endregion

        #region Properties

        public CalModel Data
        {
            get { return _data; }
            set { _data = value; }
        }

        #endregion

        #region Methods

        public int Calculate()
        {
            int result = 0;
            if (this.Data != null)
            {
                switch (this.Data.Operation)
                {
                    case CalOperations.Add:
                        result = this._calculator.Add(this.Data.integerValue1, this.Data.integerValue2);
                        break;
                    case CalOperations.Sub:
                        result = this._calculator.Sub(this.Data.integerValue1, this.Data.integerValue2);
                        break;
                    case CalOperations.Mul:
                        result = this._calculator.Mul(this.Data.integerValue1, this.Data.integerValue2);
                        break;
                    case CalOperations.Div:
                        result = this._calculator.Div(this.Data.integerValue1, this.Data.integerValue2);
                        break;
                    case CalOperations.AddList:
                        result = this._calculator.AddList(this.Data.listOfIntegerValue);
                        break;
                }
            }
            else
            {
                Console.WriteLine("There is no data to be calculated!");
            }
            return result;
        }

        #endregion

    }

    public enum CalOperations { Add, Mul, Div, Sub, AddList }

}
